package com.bdqn.spark.chapter05.action

import org.apache.spark.{SparkConf, SparkContext}

object Spark10_RDD_Operator_Action {
  def main(args: Array[String]): Unit = {
    val sparkConf = new SparkConf().setMaster("local[4]").setAppName("action-saveAs%")
    val sc = new SparkContext(sparkConf)

//    val rdd = sc.makeRDD(List(1,2,3,4),2)
    val rdd = sc.makeRDD(List(
      ("a", 1), ("a", 2), ("a", 3)
    ))

    // 行动算子
    rdd.saveAsTextFile("output1")
    rdd.saveAsObjectFile("output2")
    // saveAsSequenceFile方法要求数据的格式必须为K-V类型
    rdd.saveAsSequenceFile("output3")

    sc.stop()
  }
}
